package com.education.student.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.education.model.CourseInform;
import com.education.model.ResultDo;
import com.education.service.INoticeService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


/**
 * Created by 曹朋 on 2017/8/8.
 */
@Api(value="/api/student",description="公告详情")
@Controller
@RequestMapping(path = "/api/student")
public class CourseNoticeContrller {
    /**
     * 注入公告Service接口
     */
    @Reference
    private INoticeService ins;

    /**
     * 获取课程公告
     * @param pageSize   当前页条数
     * @param pageNum    总页数
     * @return 返回所有通知信息
     */
    @ApiOperation(notes="notices/course",httpMethod="GET",value="获取课程公告")
    @RequestMapping(path = "/notices/course" , method = RequestMethod.GET)
    @ResponseBody
    public ResultDo<PageInfo<CourseInform>> selectNoticeById(HttpSession session,Integer pageSize, Integer pageNum) throws Exception {
        int  stuId=(int)session.getAttribute("stuId");
        PageInfo<CourseInform> page = ins.getCourseNoticeInfo(stuId,pageNum, pageSize);

        ResultDo<PageInfo<CourseInform>> res = new ResultDo<>(page);

        return res;
    }
}